package com.bulemobi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.bulemobi.bean.BankCarBean;
import com.jsyh.hcb.R;

import java.util.ArrayList;

/**
 * Created by 武 on 2014/9/24 0024.
 * popupwindow 适配器
 */
public class PopItemAdapter extends BaseAdapter{
    private Context mContext;
    private LayoutInflater layoutInflater;
    private ArrayList<BankCarBean> popList;

    public PopItemAdapter(Context context, ArrayList<BankCarBean> list) {
        this.mContext = context;
        this.popList = list;
        this.layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return popList == null ? 0 : popList.size();
    }

    @Override
    public Object getItem(int position) {
        return popList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        TextView tv_label;
        if (null == mContext) {
            return null;
        }
        if (null == convertView) {
            convertView = layoutInflater.from(mContext).inflate(R.layout.pop_lv_item,null);
        }
        tv_label = (TextView) convertView.findViewById(R.id.tv_label);
        tv_label.setText(popList.get(position).getBankName());
        return convertView;
    }
}
